<template>
	<div class="record-item" @click="toPage">
		<div class="title">
			<img :src="statusImg[details?.pczt]" alt="" />
			<h3>房屋编号：{{ details?.fwbh }}</h3>
		</div>
		<div class="item" v-for="(value, key) in dataEnum" :key="key">
			<p>{{ value === '时间' ? `${details?.yhly}时间` : value   }}</p>
			<p>{{ details?.[key] || '-' }}</p>
		</div>
	</div>
</template>

<script setup>
import { defineProps } from 'vue'
import { useRoute, useRouter } from 'vue-router'

const props = defineProps({
	details: {
		type: Object,
		default: () => {}
	}
})

const route = useRoute()
const router = useRouter()
const dataEnum = {
	'hzxm': '房主姓名',
	'address': '地址',
	'createOn': '时间',
	'createName': '检查人员',
	'pczt': '有无隐患',
}
const statusImg = {
	'无隐患': require('./../image/trouble_no.png'),
	'有隐患': require('./../image/trouble_has.png'),
}

const toPage = () => {
	router.push({
		name: 'check-record-record-info',
		query: {
			id: props.details?.id,
			type: props.details?.yhly === '检查' ? 1 : 2,
			fwbh: props.details?.fwbh
		}
	})
}

</script>

<style scoped lang="less">
.record-item {
	margin: 0 32px 24px;
	padding: 24px 32px;
	box-shadow: 0 0 16px 0 rgba(0, 0, 0, .14);
	border-radius: 8px;
	background: #fff;
	h3 {
		margin-bottom: 22px;
	}
	.title {
		display: flex;
		img {
			width: 48px;
			height: 48px;
			margin-right: 12px;
		}
		h3 {
			width: 0;
			flex: 1;
			min-height: 48px;
			line-height: 48px;
		}
	}
	.item {
		display: flex;
		margin-top: 4px;
		p {
			min-height: 44px;
			line-height: 44px;
			&:nth-of-type(1) {
				width: 160px;
				color: #A0A0A0;
			}
			&:nth-of-type(2) {
				width: 0;
				flex: 1;
				color: #696969;
			}
		}
	}
	.btns {
		display: flex;
		justify-content: flex-end;
		gap: 24px;
		border-top: 2px solid var(--border-color);
		margin-top: 24px;
		padding-top: 20px;
		div {
			height: 50px;
			line-height: 50px;
			background: var(--van-primary-color);
			color: #fff;
			border-radius: 12px;
			padding: 0 12px;
		}
	}
}
</style>
